{include 'header.tpl'}
<ol class="breadcrumb">
    <li><a href="/adminmall/Order/list">小红薯订单管理列表</a></li>
    <li><a href="/adminmall/Order/list?status=1">待付款订单</a></li>
    <li><a href="/adminmall/Order/list?status=2">待接单订单</a></li>
    <li><a href="/adminmall/Order/list?status=3">商家已接的订单</a></li>
    <li><a href="/adminmall/Order/list?status=4">派送中的订单</a></li>
    <li><a href="/adminmall/Order/list?status=5">已完成的订单</a></li>
    <li><a href="/adminmall/Order/list?status=6">已取消的订单</a></li>
    <li><a href="/adminmall/Order/Peizhi?id=1">起送价格配置</a></li>
</ol>
<form method="get" action="/Order/list" class="form-inline">
    <table>
        <tr>

            <td>
                <label for="form-w" class="control-label">订单号：</label>
                <input class="form-control" id="o_id" name="o_id" value="{$smarty.get.o_id}" placeholder="" size="20"/>
            </td>

            <td>
                <label for="form-w" class="control-label">昵称：</label>
                <input class="form-control" id="nickname" name="nickname" value="{$smarty.get.nickname}" placeholder="" size="6"/>
            </td>

            <td>
                <label for="form-w" class="control-label">联系电话：</label>
                <input class="form-control" id="mobile" name="mobile" value="{$smarty.get.mobile}" placeholder="" size="10"/>
            </td>


            <td>
                <label for="form-w" class="control-label">时间范围：</label>
                <input type="text" class="date-picker" id="begin_date" name="begin_date" value="{$start_time}" style="width: 85px;"/> 至 <input type="text" class="date-picker" id="end_date" name="end_date" value="{$end_time}" style="width: 85px;"/>
            </td>
            <td>
                <label for="form-w" class="control-label">订单状态：</label>
                <select id="status" name="status" class="form-control" style="width: 135px;padding-left: 4px;padding-right: 4px;">
                    <option  {if $smarty.get.status eq ""}selected{/if} value="">请选择订单状态</option>
                    <option  {if $smarty.get.status eq 1}selected{/if} value="1">待付款</option>
                    <option  {if $smarty.get.status eq 2}selected{/if} value="2">待接单</option>
                    <option  {if $smarty.get.status eq 3}selected{/if} value="3">商家已接单</option>
                    <option  {if $smarty.get.status eq 4}selected{/if} value="4">派送中</option>
                    <option  {if $smarty.get.status eq 5}selected{/if} value="5">已完成</option>
                    <option  {if $smarty.get.status eq 6}selected{/if} value="6">已取消</option>
                </select>
            </td>

            <td>
                <button type="submit" class="btn btn-primary">查找</button>
                {*<a href="/admin/Order/list" class="btn btn-danger">清空条件</a>*}
                <button type="button" onclick="dao()" class="btn btn-primary">导出</button>
            </td>
        </tr>
    </table>
</form>
<div class="clearfix" style="height:30px;"></div>
<table class="table" style="table-layout: fixed;WORD-BREAK: break-all; WORD-WRAP: break-word">
    <tr>
        <td>订单号</td>
        <td>用户id</td>
        <td>昵称</td>

        <td style="width: 30%;">商品详情</td>
        <td>总成本</td>
        <td>商品总金额</td>
        <td>配送费</td>
        <td>实际配送费</td>
        <td>优惠金额</td>
        <td>订单支付金额</td>
        <td>配送店</td>
        <td style="width: 10%">收货详情</td>
        <td>总利润</td>
        <td>接单耗时</td>
        <td>制作耗时</td>
        <td>配送耗时</td>
        <td style="width: 6%">支付时间</td>
        <td>状态</td>
        <td>操作</td>
    </tr>
    {foreach from=$data item=item}
        <tr>
            <td>{$item.o_id}</td>
            <td>{$item.uid}</td>
            <td>{$item.username}</td>
            {$products = ""}

            {foreach $item.products as $k1 => $v1}
                {$new = ""}
                {$products = "$products {$v1['title']} 数量:{$v1['paynum']}"}
                {$tmp = json_decode($v1['spec_list'])}
                {foreach $tmp as $k => $v}
                    {$new = json_decode($v)}
                {/foreach}
                {$products = "{$products} 规格:{$new->value}<br>"}
            {/foreach}
            <td style="text-align: left">{$products}</td>
            {*<td>{$item.unit}</td>*}
            {*<td>*}
                {*{$tmp = json_decode($item.spec_list)}*}
                {*{foreach $tmp as $k => $v}*}
                    {*{$new = json_decode($v)}*}
                    {*{$new->value}*}
                {*{/foreach}*}
            {*</td>*}
            {*<td>{$item.paynum}</td>*}

            <td style="color: red">{$item.purchase_price}</td>
            <td style="color: red">{$item.price}</td>
            <td style="color: red">{$item.send_price}</td>
            <td style="color: red">{$item.real_send_price}</td>
            <td style="color: red">{$item.youhui_price}</td>
            <td style="color: red">{$item.pay_price}</td>
            <td>{$item.shop_name}</td>

            <td style="text-align: left">
                收货人:{$item.contact}<br>
                电话:{$item.phone}<br>
                地址:{$item.address}
            </td>

            <td>{$item.profit}</td>
            <td>{Service_Order::timeFormat($item.recv_expend)}</td>
            <td>{Service_Order::timeFormat($item.make_expend)}</td>
            <td>{Service_Order::timeFormat($item.send_expend)}</td>
            <td>{if $item.pay_time neq '1970-01-01 00:00:00'}{$item.pay_time}{/if}</td>
            <td>
                {if $item.status eq 1}<span style="color: #9d9d9d;">待付款</span>{/if}
                {if $item.status eq 6}<span style="color: #9B410E">已取消</span>{/if}
                {if $item.status eq 5}<span style="color: #1c8ede">已完成</span>{/if}
                {if $item.status gt 1 and $item.status lt 5}
                    {if $item.status eq 2}<a href="/Order/modifyStatus?id={$item.auto_id}&status=3">待接单</a>{else}待接单{/if}
                    <span style="font-size: 25px;">⇒</span>{if $item.status eq 3}<a href="/Order/modifyStatus?id={$item.auto_id}&status=4">商家已接单</a>{else}商家已接单{/if}
                    <span style="font-size: 25px;">⇒</span>{if $item.status eq 4}<a href="/Order/modifyStatus?id={$item.auto_id}&status=5">派送中</a>{else}派送中{/if}
                    <span style="font-size: 25px;">⇒</span>{if $item.status eq 5}<a href="#">已完成</a>{else}已完成{/if}
                {/if}

            </td>
            <td>

                {if $item.status neq 1 and $item.status neq 5  and $item.status neq 6}<a href="/Order/orderDeal?id={$item.auto_id}&status=6" rel="ajax">取消订单</a>{/if}
                {if $item.status neq 1 and $item.status neq 5  and $item.status neq 6}<a href="/Order/orderDeal?id={$item.auto_id}&status=2" rel="ajax">拒绝接单</a>{/if}
                <a href="/Order/orderModify?id={$item.auto_id}" rel="">修改</a>
                {*{if $item.status eq 3 and $item.ship_status eq 1}
                    <a href="/Order/cancelDistribution?id={$item.auto_id}" rel="">取消配送</a>
                {/if}*}

                {*<a onclick="return confirm('确定要删除此域名？');" href="/Order/modifyStatus?id={$item.auto_id}&status=-1"  rel="ajax" >删除</a>*}
            </td>
        </tr>
    {/foreach}
</table>
{include "pager.tpl"}
<script type="text/javascript">
    $(function () {
        create_date_picker();
    });

    function dao(){
        var nickname = $('#nickname').val();
        var mobile = $('#mobile').val();
        var o_id = $('#o_id').val();
        var begin_date = $('#begin_date').val();
        var end_date = $('#end_date').val();
        var intentionE1=$("#status option:selected");
        var status = intentionE1.val();
//        alert(intention);
//        alert(nickname);
//        alert(mobile);
//        alert(end_date);

        location.href = "/adminmall/order/excelDao?begin_date=" + begin_date + "&end_date=" + end_date+ "&nickname=" + nickname+ "&mobile=" + mobile + "&status=" + status + "&o_id=" + o_id;

    }
</script>
{include 'footer.tpl'}